package cc.vicp.djx314.starfood.service.order.impls;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cc.vicp.djx314.starfood.dao.dish.DishMapper;
import cc.vicp.djx314.starfood.domain.dish.Dish;
import cc.vicp.djx314.starfood.service.exception.DishNotFoundException;
import cc.vicp.djx314.starfood.service.order.CartService;

@Service
public class CartServiceImpl implements CartService {
	@Autowired
	DishMapper dishMapper;

	@Override
	@Transactional(readOnly = true)
	public Dish findDishForCart(Integer id) throws DishNotFoundException {
		Dish cartDish = dishMapper.findDishForCart(id);
		if (cartDish == null) {
			throw new DishNotFoundException(new StringBuilder("id为").append(id).append("的菜式没有找到").toString());
		}
		return cartDish;
	}
}